﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SharpSoft.Geometries
{
    public struct Size2D
    {
        public Size2D(double w, double h)
        {
            if (w < 0 || h < 0)
            {//Size的宽和高均不允许为负数
                throw new Exception("The Width Or Height Cannot Be Negative.");
            }
            this._Width = w;
            this._Height = h;
        }

        private double _Width;

        public double Width
        {
            get { return _Width; }
            set
            {

                if (value < 0)
                {
                    throw new Exception("The Width Cannot Be Negative.");
                }
                _Width = value;
            }
        }

        private double _Height;

        public double Height
        {
            get { return _Height; }
            set
            {
                if (value < 0)
                {
                    throw new Exception("The Height Cannot Be Negative.");
                }
                _Height = value;
            }
        }


        public override bool Equals(object obj)
        {
            if (obj is Size2D s)
            {
                return s.Width == this.Width && s.Height == this.Height;
            }
            return false;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}